/**
 * Created by MyPC on 2017/7/23.
 */
const SUCCESS_CODE = 1;
const FAIL_CODE = 0;
const ERROR_CODE = 2;

const obj = {};

obj.success = function (res, data, message) {
  let json = {
    'result': SUCCESS_CODE,
    'msg': message?message:'success',
    'data': data
  }
  res.json(json);
}

obj.fail = function (res, message, data) {
  let json = {
    'result': FAIL_CODE,
    'msg': message,
    'data': data
  }
  res.json(json);
}

obj.error = function (res, data, message) {
  let json = {
    'result': ERROR_CODE,
    'msg': message?message:'系统繁忙,请稍后再试',
    'data': data
  }
  res.json(json);
}

module.exports = obj;